package com.hbk.pojos;

<#list imports as import>
${import}
</#list>

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.*;

@Entity
@Table(name = "${table}")
@org.hibernate.annotations.Table(appliesTo = "${table}", comment = "${comment}")
public class ${clazz} implements BaseEntity{

<#list fields as field>
	<#list field.constant as cons>
	/**${cons.comment}*/
	public static final ${cons.type} ${field.name?upper_case}_${cons.var}=<#if (field.type=='String')>"${cons.value}"<#else>${cons.value}</#if>;
	
	</#list>
</#list>

<#list fields as field>
	<#if (field.name=='id')>
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private ${field.type} ${field.name};
	<#elseif field.getFetch()?index_of("ManyToOne")!=-1>
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "${field.column}", columnDefinition = "BIGINT COMMENT '${field.getComment()}'")
	private ${field.type} ${field.name};
	<#elseif field.getFetch()?index_of("OneToMany")!=-1>
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "${clazz?uncap_first}", cascade = {CascadeType.ALL})
	private ${field.type} ${field.name};
	<#else>
	@Column(name = "${field.column}", columnDefinition = "${field.getDataType()} COMMENT '${field.getComment()}<#list field.constant as con> ${con.value}:${con.comment};</#list>'")
	private ${field.type} ${field.name};
	</#if>

</#list>
	public ${clazz} (){}

	public ${clazz} (Long id){
		this.id=id;
	}

<#list fields as field>
	public ${field.type} get${field.name?cap_first}(){
		return this.${field.name};
	}
	
	public void set${field.name?cap_first}(${field.type} ${field.name}){
		this.${field.name}=${field.name};
	}
	
</#list>

}
